package org.langqiao.serializable;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

public class ReadObject {

	public static void main(String[] args) {
		ObjectInputStream ois = null;
		try{
			ois = new ObjectInputStream(new FileInputStream("object.txt"));
			Person p = (Person) ois.readObject();
			String name = p.getName();
			int age = p.getAge();
			System.out.println("姓名为："+name+",年龄为："+age);
		}catch(IOException e){
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}finally{
			if(ois != null){
				try {
					ois.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

}
